package com.view.impl;

import com.dao.AccountDao;
import com.dao.impl.AccountDaoImpl;
import com.util.ReturnLevel;
import com.view.LoginView;

import java.util.List;
import java.util.Map;

import static com.util.Read.getIn;
import static com.util.ReturnLevel.returnLevel;

public class ReportView extends LoginView {
    AccountDao accountDao = new AccountDaoImpl();

    public void menua() {
        int n = 0;
        AccountDao accountDao = new AccountDaoImpl();
        while (n != 1 && n != 2) {
            System.out.println("请选择查询内容：");
            System.out.println("1.查询所有账单及总计/t2.按日期查询");
            n = getIn().nextInt();
            switch (n) {
                case 1:
                    findAll();
                    break;
                case 2:
                    findByDate();
                    break;
                default:
                    System.out.println("请输入1或2：");
                    menu();
                    break;
            }
        }
        returnLevel();
    }

    private void findByDate() {
    }

    private void findAll() {
        //从登录成功后存放的用户信息中获取商家的id
        String id = getInfo().get("a_id").toString();
        List<Map<String, Object>> list = accountDao.findAll(id);
        System.out.println("支出\t收入\t备注\t日期\t总支出\t总收入");
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = list.get(i);
            Object ac_out = map.get("ac_out");
            Object ac_in = map.get("ac_in");
            Object ac_info = map.get("ac_info");
            Object ac_date = map.get("ac_date");
            Object allout = map.get("allout");
            Object allin = map.get("allin");
            System.out.println(ac_out + "\t" + ac_in + "\t" + ac_info + "\t" + ac_date+ "\t" +allout+ "\t" +allin);

        }
        ReturnLevel.returnLevel();
    }

}
